import {
  Column,
  Entity,
  Index,
  OneToMany,
  PrimaryGeneratedColumn,
} from 'typeorm';
import { BookEntity } from 'src/books/entities/book.entity';

@Index('name', ['name'], {})
@Entity('book_cate', { schema: 'db_book' })
export class CateEntity {
  @Column('varchar', { name: 'name', comment: '小说类别', length: 255 })
  name: string;

  @PrimaryGeneratedColumn({ type: 'int', name: 'id' })
  id: number;

  @Column('text', { name: 'pic', nullable: true })
  pic: string | null;

  @OneToMany(() => BookEntity, (bookEntity) => bookEntity.category2)
  bookBooks: BookEntity[];
}
